<template>

			
		
					<view class="example">
						<!-- 基础用法，不包含校验规则 -->
						<uni-forms ref="baseForm" >
							<uni-forms-item label="">
								<uni-datetime-picker type="date" :clear-icon="false" v-model="endTime" @maskClick="maskClick" />
							</uni-forms-item>
							<uni-forms-item label="" >
								<uni-easyinput v-model="context" placeholder="请输入待办内容" />
							</uni-forms-item>
						
							<uni-forms-item label="">
								<uni-easyinput type="textarea" v-model="comment" placeholder="请输入待办备注" />
							</uni-forms-item>
							
								<button type="primary" @click="submit()">保存</button>
						
						
						</uni-forms>
					</view>
			
			
					
				
</template>

<script>
	import store from '@/store/index.js';//需要引入store
	var date=new Date();
	var year=date.getFullYear();
	var month=date.getMonth()<9?"0"+(date.getMonth()+1):(date.getMonth()+1)
	var day =date.getDate()<10?"0"+date.getDate():date.getDate();
	var nowDate=year+"-"+month+"-"+day;
	export default {
			data() {
				return {
					
					endTime: nowDate,
					context:"",
					comment:"",
					todoId:"",
					
					
					
				}
			},
			onLoad(option) {
				console.log(JSON.stringify(option))
				if(option.id!=undefined){
					this.todoId=option.id;
					this.context=option.context;
					this.endTime=option.endTime;
					this.comment=option.comment;
				}
			
				
				
			},
			watch: {
			
			},
			mounted() {
				// setTimeout(() => {
				// 	this.datetimesingle = Date.now() - 2*24*3600*1000
				// 	this.single = '2021-2-12'
				// 	this.datetimerange = ["2021-07-08 0:01:10", "2021-08-08 23:59:59"]
				// },3000)
			},
	
			methods:{
				change(e) {
					this.single = e
					console.log('change事件:', this.single = e);
				},
				changeLog(e) {
					console.log('change事件:', e);
				},
				maskClick(e){
					console.log('maskClick事件:', e);
				},
				submit(){
					var self=this;
					console.log(self.$data.todoId);
					console.log(self.$data.context.length);
					let entTime=self.$data.endTime;
					if(self.$data.context.length>0){
						store.dispatch('addTodoData',{"id":self.$data.todoId,"endTime":entTime,"context":self.$data.context,"comment":self.$data.comment}).then(()=>{
							uni.showToast({
								title:"发布成功",
								icon:'none'
							})
							uni.redirectTo({
								url:"/pages/todo/todoList"
							})
						
							
						});
					}else{
						
					}
					
				},
			}
		}
</script>

<style>
.example-body {
	background-color: #fff;
	padding: 10px;
}

.example {
	padding: 15px;
	background-color: #fff;
}
</style>